﻿using System;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using RegistCommon;

namespace FDEEMain
{
    public partial class RegistForm : Form
    {
        //private string filePath = Application.StartupPath + @"\RegistInfo.key";
        private string encryptComputer = string.Empty;
        public RegistForm()
        {
            InitializeComponent();
           
            Control.CheckForIllegalCrossThreadCalls = false;
        }
        private void FormMain_Load(object sender, EventArgs e)
        {
            string computer = ComputerInfo.GetComputerInfo();
            textBox1.Text = computer;
            string sysConfigPath = CurPaht.curPaht + "\\Config\\BridgeSetting.config";       
            string version = ConfigUtils.GetKey(sysConfigPath, "Version");
            lbVersionNO.Text = version;
        }
       
      
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (RegistFileHelper.ExistRegistInfofile() == true)
            {
                string key = textBox2.Text.Trim();
                if (UTool.CheckRegist(key) == true)
                {
                    
                    MessageBox.Show("注册成功！");
                    this.DialogResult = DialogResult.OK;                 
                    this.Hide();
                }
                else
                {
                    this.DialogResult = DialogResult.No;
                    MessageBox.Show("注册失败，请输入正确的注册码！");
                }
            }
            else
            {
                MessageBox.Show("缺少系统文件，请联系管理员");
            }
        }
        /// <summary>
        /// 复制
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                Clipboard.SetText(textBox1.Text);
                MessageBox.Show("已复制到剪切板");
            }
        }
         /// <summary>
         /// 取消
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Dispose();
        }
    }
}
